package com.caowei.weicimpress.weicimpress.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;

import com.caowei.weicimpress.weicimpress.R;
import com.caowei.weicimpress.weicimpress.Utils;

/**
 * Created by caoweiPc on 2014/7/20.
 */
public class ListViewRightLayout extends LinearLayout implements View.OnTouchListener{
    private final static String TAG=ListViewRightLayout.class.getSimpleName();
    private CheckBox checkBox;
    public ListViewRightLayout(Context context) {
        this(context, null);
    }

    public ListViewRightLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        setOnTouchListener(this);
    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if(Utils.DEBUG){
            Log.d(TAG,String.valueOf(event.getAction()));
        }
        if(checkBox==null){
            checkBox= (CheckBox) findViewById(R.id.checkbox);
        }
        switch (event.getAction()){
            case MotionEvent.ACTION_DOWN:
                checkBox.performClick();
                break;
        }
        return true;
    }
}
